<script setup lang="ts">

import SvgIcon from "@/components/common/SvgIcon.vue";
defineProps({
  icon: {
    type: String,
    default: '标签'
  },
  text: {
    type: String,
    default: '标签'
  },
  color: {
    type: String,
    default: '#666666'
  },
  disabledIcon: {
    type: Boolean,
    default: false
  },
  transparent: {
    type: Boolean,
    default: false
  }
})
</script>

<template>
  <div class="article-category">
    <SvgIcon v-if="!disabledIcon" class-name="article-category-icon" :icon-class="icon" :style="{background: color}"/>
    <p class="article-category-name" :style="{color: color,background: !transparent ? color : 'transparent'}">{{ text }}</p>
  </div>
</template>

<style scoped lang="less">
.article-category{
  display: flex;
  align-items: center;
  padding: 2px 0;
  &:hover{
    cursor: pointer;
  }
  .article-category-icon {
    width: 20px;
    height: 20px;
    color: white;
    padding: 4px;
    border-radius: 4px;
    z-index: 2;
  }
  .article-category-name {
    height: 26px;
    padding: 0 12px;
    font-size: 20px;
    font-weight: 500;
    border-radius: 0 4px 4px 0;
    position: relative;
    z-index: 1;
    &::after{
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(255, 255, 255, 0.87); // 用于遮罩让背景颜色减淡
      border-radius: 0 4px 4px 0;
      z-index: -1; // 用于放在背景颜色下
    }
  }
}
@media screen and (max-width: 768px) {
  .article-category{
    .article-category-icon {
      width: 14px;
      height: 14px;
      padding: 2px;
    }
    .article-category-name {
      height: 16px;
      padding: 0 8px;
      font-size: 14px;
      line-height: 16px;
    }
  }
}
</style>
